package com.example.b_308.myapplication.view.main;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.example.b_308.myapplication.R;
import com.example.b_308.myapplication.controller.IMessageView;
import com.example.b_308.myapplication.controller.MessageController;
import com.example.b_308.myapplication.view.base.BaseFragment;

import java.util.List;

/**
 * Created by B-305 on 2017/11/21.
 */
public class MessageFragment extends BaseFragment implements IMessageView{

    ListView lv_message;
    MessageAdapter messageAdapter;
    MessageController messageController;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_message,null);

        lv_message = (ListView) view.findViewById(R.id.lv_massage);
        messageController =new MessageController(this);
        messageController.getList();

        return view;
    }

    @Override
    public void onRrquestListSuccess(List<MessageBeen> messageBeens) {
//        if(null==messageAdapter){
//            messageAdapter.notifyChange(messageBeens);
//        }else{}
            messageAdapter =new MessageAdapter(messageBeens,getContext());

        lv_message.setAdapter(messageAdapter);

    }
}
